<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <!--      请选择瞬间类型0-图片 1-视频(数据字典)-->
      <el-form-item label="瞬间类型" prop="momentType">
        <!--        <el-select v-model="queryParams.momentType" placeholder="" clearable size="small">-->
        <!--          <el-option v-for="item in [{value: '0', label: '图片' }, {value: '1', label: '视频' }]"  :key="item.value" :label="item.label" :value="item.value" />-->
        <!--        </el-select>-->
        <!--        sysInstantaneousType-->
        <el-select v-model="queryParams.momentType" placeholder="选择瞬间属性 " clearable size="small" >
          <el-option
            v-for="dict in sysInstantaneousType"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="瞬间属性 ">
        <el-select v-model="queryParams.momentAttr" placeholder="选择瞬间属性 " clearable size="small" prop="status">
          <el-option
            v-for="dict in sysAttribute"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:moment:add']"
        >新增</el-button>
      </el-form-item>
    </el-form>

    <!--    <el-row :gutter="10" class="mb8">-->
    <!--      <el-col :span="1.5">-->

    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--          type="success"-->
    <!--          icon="el-icon-edit"-->
    <!--          size="mini"-->
    <!--          :disabled="single"-->
    <!--          @click="handleUpdate"-->
    <!--          v-hasPermi="['system:moment:edit']"-->
    <!--        >修改</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--          type="danger"-->
    <!--          icon="el-icon-delete"-->
    <!--          size="mini"-->
    <!--          :disabled="multiple"-->
    <!--          @click="handleDelete"-->
    <!--          v-hasPermi="['system:moment:remove']"-->
    <!--        >删除</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--          type="warning"-->
    <!--          icon="el-icon-download"-->
    <!--          size="mini"-->
    <!--          @click="handleExport"-->
    <!--          v-hasPermi="['system:moment:export']"-->
    <!--        >导出</el-button>-->
    <!--      </el-col>-->
    <!--    </el-row>-->

    <!--    瞬间表-->
    <el-table v-loading="loading" :data="momentList" >
      <el-table-column label="名称" align="center" prop="name" />
      <el-table-column label="瞬间类型" align="center" prop="momentType"  :formatter="typeFormat"/>
      <el-table-column label="瞬间属性 " align="center" prop="momentAttr" :formatter="attributeFormat" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="评论数" align="center" prop="commentTotal" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleComment(scope.row)">{{scope.row.commentTotal}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="点赞数" align="center" prop="pariseTotal" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleParise(scope.row)">{{scope.row.pariseTotal}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:moment:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:moment:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改平台精彩瞬间对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" @close='closeDialog'>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12" v-show="changeType==true">
            <el-form-item label="瞬间类型" prop="momentType">
              <!--              <el-select v-model="form.momentType" placeholder="请选择上传类型" clearable size="small">-->
              <!--                <el-option v-for="item in [{value: '0', label: '图片' }, {value: '1', label: '视频' }]"  :key="item.value" :label="item.label" :value="item.value" />-->
              <!--              </el-select>-->
              <el-select v-model="form.momentType" placeholder="选择瞬间属性 " clearable size="small" >
                <el-option
                  v-for="dict in sysInstantaneousType"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="瞬间属性" prop="momentAttr">
              <el-select v-model="form.momentAttr" placeholder="选择瞬间属性" clearable size="small">
                <el-option
                  v-for="dict in sysAttribute"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="名称" prop="name">
              <el-input v-model="form.name" placeholder="请输入名称" />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="启用状态">
              <!--          <el-radio-group v-model="form.status">-->
              <!--            <el-radio label="1">请选择字典生成</el-radio>-->
              <!--          </el-radio-group>-->
              <el-switch
                v-model="form.status"
                active-text="启用"
                active-value="0"
                inactive-text="停用"
                inactive-value="1"
                @change="momentSwitchChange">
              </el-switch>
            </el-form-item>
          </el-col>
          <!--上传图片-->
          <el-col :span="24" v-show="form.momentType=='0'">
            <el-form-item label="上传图片">
              <el-upload
                ref="uploadImg"
                class="upload-demo"
                :action="url"
                :headers="headers"
                :before-upload="imgBeforeUpload"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :on-success="handleImageSuccess"
                multiple
                list-type="picture"
                :limit="6"
                :on-exceed="handleExceed"
                :file-list="fileList">
                <el-button size="small" type="primary">点击上传图片</el-button>
                <div slot="tip" class="el-upload__tip">只能上传图片格式文件</div>
              </el-upload>
            </el-form-item>
          </el-col>

          <!--上传视频-->
          <el-col :span="24" v-show="form.momentType=='1'">
            <el-form-item label="上传视频">
              <!--     accept=".mp4, .qlv, .qsv, .ogg, .flv, .avi, .wmv, .rmvb"          -->
              <el-upload class="avatar-uploader el-upload--text"

                         :action="videoUrl"
                         :headers="headers"
                         :show-file-list="false"
                         :on-success="handleVideoSuccess"
                         :before-upload="beforeUploadVideo"
                         :on-progress="uploadVideoProcess">
                <video v-if="videoForm.Video !='' && videoFlag == false" :src="videoForm.Video" :poster="videoForm.picture" class="avatar" controls="controls" controlspreload="none" style="width: 300px;height: 200px" >您的浏览器不支持视频播放</video>
                <i v-else-if="videoForm.Video =='' && videoFlag == false" class="el-icon-plus avatar-uploader-icon"></i>
                <el-progress v-if="videoFlag == true" type="circle" :percentage="videoUploadPercent" style="margin-top:30px;"></el-progress>
                <!--                  -->
                <!--                <el-button size="small" type="primary">点击上传视频</el-button>-->
                <div slot="tip" class="el-upload__tip">只能上传视频格式文件，请保证视频格式正确，且不超过500M</div>
              </el-upload>
              <!--              </el-form-item>-->
            </el-form-item>
          </el-col>


          <el-col :span="24" style="margin-bottom: 20px">
            <el-form-item label="内容">
              <Editor v-model="form.detail"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 评论对话框 -->
    <el-dialog :title="title"  :visible.sync="openComment"  width="800px" @close='closeDialog'>
      <el-table v-loading="loading" :data="commentList" >
        <el-table-column label="名称" align="center" prop="userName" />
        <el-table-column label="内容" align="center" prop="value" />
        <el-table-column label="创建时间" align="center" prop="createDate" >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作是否展示" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleCommentOperate(scope.row)"
              v-hasPermi="['system:moment:edit']"
            >{{scope.row.status=="1"?"展示":"隐藏"}}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="commentTotal>0"
        :total="commentTotal"
        :page.sync="commentQueryParams.pageNum"
        :limit.sync="commentQueryParams.pageSize"
        @pagination="handleCommentPaper"
      />
    </el-dialog>
    <!-- 点赞对话框 -->
    <el-dialog :title="title"  :visible.sync="openParise"  width="800px" @close='closeDialog'>
      <el-table v-loading="loading" :data="pariseList" >
        <el-table-column label="名称" align="center" prop="userName" />
        <el-table-column label="点赞时间" align="center" prop="createDate" >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createDate) }}</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="pariseTotal>0"
        :total="pariseTotal"
        :page.sync="pariseQueryParams.pageNum"
        :limit.sync="pariseQueryParams.pageSize"
        @pagination="handleParisePaper"
      />
    </el-dialog>
  </div>
</template>

<script>
  import { listMoment, getMoment, delMoment, addMoment, updateMoment, exportMoment } from "@/api/system/moment";
  import { listFile, getFile, delFile, addFile, updateFile, exportFile } from "@/api/system/file";
  import { listComment, getComment, delComment, addComment, updateComment, exportComment } from "@/api/system/comment";
  import { listParise, getParise, delParise, addParise, updateParise, exportParise } from "@/api/system/parise";

  import Editor from '@/components/Editor';
  import { getToken } from '@/utils/auth'
  import { upload } from "@/api/system/type";
  export default {
    name: "Moment",
    components: {
      Editor
    },
    data() {
      return {
        //是否显示更改类型   编辑时候不能修改类型
        changeType:true,
        //视频上传
        videoUrl:'',
        //保存视频
        videoForm:{
          Video:''
        },
        videoUploadPercent:0,
        // 不显示进度条
        videoFlag :false,
        // // //上传headers
        headers:{
          'Authorization': null
        },
        videoHeaders:{
          'Authorization': null,
          'Content-Type':'application/x-www-form-urlencoded'
        },
        // //url  上传接口地址
        url:null,
        //上传文件列表
        fileList:[],
        //文件分类汇总
        fileListItems:[],
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        statusOptions:[],
        total: 0,
        commentTotal:0,
        pariseTotal:0,
        // 平台精彩瞬间表格数据
        momentList: [],
        // 评论表格数据
        commentList: [],
        // 点赞表格数据
        pariseList: [],
        // 弹出层标题
        title: "",
        // 是否显示新增修改弹出层
        open: false,
        // 是否显示评论弹出层
        openComment: false,
        // 是否显示点赞弹出层
        openParise: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          momentType: undefined,
          name: undefined,
          detail: undefined,
          videoUrl: undefined,
          status: undefined,
          momentAttr:undefined,
        },
        //评论详情 查询参数
        commentQueryParams: {
          momentId: null,
          pageNum: 1,
          pageSize: 10
        },
        handleCommentItem:{},
        //评论详情 查询参数
        pariseQueryParams: {
          momentId: null,
          pageNum: 1,
          pageSize: 10
        },
        handlePariseItem:{},
        //点赞详情 查询参数
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        },
        //瞬间属性
        sysAttribute:[],
        //  瞬间类型
        sysInstantaneousType:[]
      };
    },
    created() {

      //瞬间属性
      this.getDicts("sys_attribute").then(response => {
        this.sysAttribute = response.data;
      });
      //瞬间类型  momentType
      this.getDicts("sys_instantaneous_type").then(response => {
        this.sysInstantaneousType = response.data;
      });
      this.getList();
      this.getUrl()  //获取拼接url
    },
    methods: {

      attributeFormat(row, column) {
        return this.selectDictLabel(this.sysAttribute, row.momentAttr);
      },
      typeFormat(row, column) {
        return this.selectDictLabel(this.sysInstantaneousType, row.momentType);
      },
      //上传视频*****************************************
      //验证方法：验证视频格式和视频大小
      beforeUploadVideo(file) {
        const isLt500M = file.size / 1024 / 1024 < 500;
        if (['video/mp4', 'video/ogg', 'video/flv', 'video/avi', 'video/wmv', 'video/rmvb'].indexOf(file.type) == -1) {
          this.$message.error('请上传正确的视频格式');
          return false;
        }
        if (!isLt500M) {
          this.$message.error('上传视频大小不能超过500MB哦!');
          return false;
        }
      },
      // 上传进度显示
      uploadVideoProcess(event, file, fileList) {
        this.videoFlag = true;
        this.videoUploadPercent = Number(file.percentage.toFixed(0)) ;
      },
      // 上传成功：

      handleVideoSuccess(res, file) {                               //获取上传图片地址
        this.videoFlag = false;
        this.videoUploadPercent = 0;
        console.log(res)
        if(res.code == 200){
          // this.videoForm.videoUploadId = res.data.uploadId;
          // this.videoForm.Video =  process.env.VUE_APP_BASE_API+'/common/uploadVideo' + res.data.url;
          // this.videoForm.fileName = process.env.VUE_APP_BASE_API+'/common/uploadVideo' + res.data.fileName;
          // this.videoForm.picture = process.env.VUE_APP_BASE_API+'/common/uploadVideo' + res.data.picture;
          this.videoForm.Video =  process.env.VUE_APP_BASE_API + res.data.url;
          this.videoForm.fileName = process.env.VUE_APP_BASE_API+ + res.data.fileName;
          this.videoForm.picture = process.env.VUE_APP_BASE_API+ + res.data.picture;
          this.form.videoUrl = res.data.url
          console.log('页面videoform',this.videoForm)
        }else{
          this.$message.error('视频上传失败，请重新上传！');
        }
      },

      //关闭对话框
      // @close='closeDialog'
      closeDialog(){
        this.open  = false
        this.openComment  = false
        this.openParise  = false
        this.changeType = true
        this.reset();
        if (!!this.$refs.uploadImg) this.$refs.uploadImg.clearFiles()
      },
      //点击表格评论
      handleComment(e){
        // console.log('表格评论',e)
        this.handleCommentItem = e
        // console.log('表格评论',e)
        this.commentQueryParams.momentId = e.momentId
        console.log(this.commentQueryParams)
        getComment(this.commentQueryParams).then(res=>{
          console.log('表格评论详细信息',res)
          this.commentList = res.rows
          this.commentTotal = res.total;
          this.openComment=true
          this.title = "评论详情"
        })
      },
      //评论分页
      handleCommentPaper(){
        var e =  this.handleCommentItem
        this.commentQueryParams.momentId = e.momentId
        console.log(this.commentQueryParams)
        getComment(this.commentQueryParams).then(res=>{
          console.log('表格评论详细信息',res)
          this.commentList = res.rows
          this.commentTotal = res.total;
          this.openComment=true
          this.title = "评论详情"
        })
      },
      //评论操作展示
      handleCommentOperate(e){
        console.log(e)
        if (e.status=="1" ){
          e.status="0"
        }else if(e.status=="0" ){
          e.status="1"
        }
        updateComment(e).then(res=>{
          console.log(res)
        })
      },
      //点击表格点赞
      handleParise(e){
        // console.log('表格点赞',e)
        this.handlePariseItem = e
        this.pariseQueryParams.momentId = e.momentId
        getParise(this.pariseQueryParams).then(res=>{
          console.log('表格点赞详细信息',res)
          this.pariseList = res.rows
          this.pariseTotal = res.total;
          this.openParise=true
          this.title = "点赞详情"
        })
      },
      //点赞分页
      handleParisePaper(){
        var e =  this.handlePariseItem
        this.pariseQueryParams.momentId = e.momentId
        getParise(this.pariseQueryParams).then(res=>{
          console.log('表格点赞详细信息',res)
          this.pariseList = res.rows
          this.pariseTotal = res.total;
          this.openParise=true
          this.title = "点赞详情"
        })
      },
      getUrl(){
        console.log("接口前缀", process.env.VUE_APP_BASE_API)
        //******************************************************************************
        let url =   process.env.VUE_APP_BASE_API+'/common/upload/'
        let videoUrl =   process.env.VUE_APP_BASE_API+'/common/uploadVideo'
        //192.168.0.100:8082/manage/common/uploadVideo
        this.url = url
        // 图片上传
        this.videoUrl = videoUrl
        // this.apiUrl = url
        console.log("整体图片接口",url)
        console.log("整体视频接口",videoUrl)
        this.headers.Authorization ='Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
        this.videoHeaders.Authorization ='Bearer ' + getToken()
      },
      //momentSwitchChange  瞬间启用停用
      momentSwitchChange(e){
        console.log(e)
        console.log(this.form.status)
      },
      //上传图片************************************************************
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 6 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
      },
      handleImageSuccess(res, file, fileList) {
        console.log('res',res)
        console.log('file',file)
        console.log('fileList',fileList)
        console.log(this.form)
        this.form.urls.length = 0
        fileList.forEach((items,i)=>{
          console.log(items)
          if(!!items.response){
            this.form.urls.push(items.response.fileName)
          }else {
            this.form.urls.push(items.url)
          }
          // console.log(this.form.urls)
        })
        console.log(this.form)
      },
      handleRemove(file, fileList) {
        this.fileList.length=0
        // this.form.typeUrl = ""
        // this.form.urls
        // console.log( this.form)
        // console.log(this.fileList)
        console.log( fileList);
        console.log(file);
        // this.fileList.length = 0
        // fileList.forEach((items,i)=>{
        //   var obj = {name:'',url:process.env.VUE_APP_BASE_API+items,response:{fileName:items}}
        //   this.form.urls.push(items)
        //   this.fileList.push(obj)
        // })

        this.form.urls.length = 0
        fileList.forEach((items,i)=>{
          console.log(items)
          if(!!items.response){
            this.form.urls.push(items.response.fileName)
          }else {
            this.form.urls.push(items.url)
          }
          // console.log(this.form.urls)
        })
      },
      handlePreview(file) {
        console.log(file);
      },
      imgBeforeUpload(file){
        let types = ['image/jpeg', 'image/gif', 'image/bmp', 'image/png'];
        const isImage = types.includes(file.type);
        const isLtSize = file.size / 1024 / 1024 < 5;
        if (!isImage) {
          this.$message.error('上传图片只能是 JPG、GIF、BMP、PNG 格式!');
          return false;
        }
        if (!isLtSize) {
          this.$message.error('上传图片大小不能超过 5MB!');
          return false;
        }
        return true;
      },
      // 上传图片
      uploadImg(file) {
        this.$refs.cropper.getCropBlob(data => {
          console.log(data)
          let formData = new FormData();
          formData.append("avatarfile", data);
          console.log(formData);
          //******************************************************************************************
          upload(formData).then(response => {
            // uploadAvatar(formData).then(response => {
            console.log(response)
            //拿到图片地址
            // this.form.typeUrl = response.imgUrl
            // console.log(this.form.typeUrl)
            if (response.code === 200) {
              this.openhead = false;
              this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl;
              this.msgSuccess("修改成功");
            } else {
              this.msgError(response.msg);
            }
            this.$refs.cropper.clearCrop();
          }).catch(err=>{
            console.log(err)
          });
        });
      },
      /** 查询平台精彩瞬间列表 */
      getList() {
        this.loading = true;
        console.log('搜索条件',this.queryParams)
        listMoment(this.queryParams).then(response => {
          console.log('查询平台精彩瞬间列表',response)
          this.momentList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.openParise = false
        this.openComment = false
        this.reset();
        if (!!this.$refs.uploadImg) this.$refs.uploadImg.clearFiles()
      },
      // 表单重置
      reset() {
        this.form = {
          momentId: undefined,
          momentType: undefined,
          name: undefined,
          detail: undefined,
          videoUrl: undefined,
          status: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          urls:[]
        };
        this.fileList.length=0
        this.videoForm={
          Video:''
        },
          this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.momentId)
        this.single = selection.length!=1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.changeType = true
        this.title = "添加平台精彩瞬间";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const momentId = row.momentId || this.ids
        getMoment(momentId).then(response => {
          console.log('修改平台精彩瞬间',response)
          //视频
          this.videoForm.Video =  process.env.VUE_APP_BASE_API + response.data.sysMoment.videoUrl;
          this.videoForm.fileName = process.env.VUE_APP_BASE_API+ response.data.sysMoment.videoUrl;
          // this.videoForm.picture = process.env.VUE_APP_BASE_API+ + res.data.picture;
          // this.form.videoUrl = res.data.url
          //图片
          this.form = response.data.sysMoment;
          this.form.urls=[]
          var imgList = response.data.list
          this.fileList.length = 0
          imgList.forEach((items,i)=>{
            // var obj = {name:'',response:{fileName:items}}
            var obj = {name:'',url:process.env.VUE_APP_BASE_API+items,response:{fileName:items}}
            this.form.urls.push(items)
            this.fileList.push(obj)
          })
          this.open = true;
          this.changeType = false
          this.title = "修改平台精彩瞬间";
        });
      },
      /** 提交按钮 */
      submitForm: function() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            console.log('提交的参数',this.form)
            if (this.form.momentId != undefined) {
              updateMoment(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                  if (!!this.$refs.uploadImg) this.$refs.uploadImg.clearFiles()
                } else {
                  this.msgError(response.msg);
                }
              });
            } else {
              addMoment(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
                } else {
                  this.msgError(response.msg);
                }
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const momentIds = row.momentId || this.ids;
        this.$confirm('是否确认删除平台精彩瞬间编号为"' + momentIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delMoment(momentIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有平台精彩瞬间数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportMoment(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
      }
    }
  };
</script>
